// You have generated a new plugin project without
// specifying the `--platforms` flag. A plugin project supports no platforms is generated.
// To add platforms, run `flutter create -t plugin --platforms <platforms> .` under the same
// directory. You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms.

import 'package:base_lib/index.dart';
import 'package:doctor_inquiry_lib/doctor_inquiry_componet.dart';
import 'package:doctor_login_lib/component.dart';
import 'package:doctor_login_lib/cache/userinfo_cache.dart';
import 'package:flutter/material.dart';
import 'chat_list/chat_list_widget.dart';
import 'package:base_lib/base_lib.dart';

import 'inquiry_plugin.dart';

class DoctorInquiryLib {
  static void doInit() {
    App.initializer([DoctorInquiryComponent(), DoctorLoginComponent()],
        DoctorLoginComponent.loginPage, DoctorInquiryComponent.chatListPage);
  }

  static void initWithContext(BuildContext context) {
    ScreenAdapter.getInstance().init(context);
  }

  static void jump2Login(BuildContext context) {
    Routers.navigateTo(context, DoctorLoginComponent.loginPage);
  }

  static void imLogin(BuildContext context) async {
    var user = await UserInfoCache.getInstance().get();
    if (user == null) {
      ToastUtil.error('请先登录');
      return;
    }

    await ChatListWidget.doImLogin(user.keyID);
    Routers.navigateTo(context, DoctorInquiryComponent.chatListPage);
  }
}

class TipWrap extends StatelessWidget {
  final Widget child;

  TipWrap(this.child);

  @override
  Widget build(BuildContext context) {
    return OverlaySupport(
      child: child,
    );
  }
}
